package com.hongyuan.coach.ui.member.fragment;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.Nullable;
import androidx.lifecycle.ViewModelProviders;

import com.hongyuan.coach.R;
import com.hongyuan.coach.base.AppViewModelFactory;
import com.hongyuan.coach.base.CustomFragment;
import com.hongyuan.coach.data.Constants;
import com.hongyuan.coach.databinding.FragmentMemberBinding;
import com.hongyuan.coach.databinding.FragmentMemberInformationBinding;
import com.hongyuan.coach.ui.member.beans.MemberInfoBeans;
import com.hongyuan.coach.ui.member.view_mode.MemberInformationViewModel;
import com.hongyuan.coach.ui.member.view_mode.MemberViewModel;

import me.tatarka.bindingcollectionadapter2.BR;

public class MemberInformationFragment extends CustomFragment<FragmentMemberInformationBinding, MemberInformationViewModel> {


    @Override
    public int initContentView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        return R.layout.fragment_member_information;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    @Override
    public MemberInformationViewModel initViewModel() {
        //使用自定义的ViewModelFactory来创建ViewModel，如果不重写该方法，则默认会调用NetWorkViewModel(@NonNull Application application)构造方法
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getActivity().getApplication());
        return ViewModelProviders.of(this, factory).get(MemberInformationViewModel.class);
    }

    @Override
    public void initView() {
        super.initView();
        setOnRefresh(binding.refresh,REFRESH_0X4);
    }

    @Override
    public void initData() {
        super.initData();

    }

    /*
    * 获取activity传来的基本数据
    * */
    public void setInfoData(MemberInfoBeans.InfoBean infoData){
        viewModel.info.set(infoData);
    }
}
